import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:old_shop/common/const/cosnt.dart';

class MineCellView extends StatelessWidget {
  final List<String> titles;
  final List<IconData> imgs;
  final Function(int index)? onTap;

  const MineCellView({Key? key, required this.titles, required this.imgs, this.onTap}) : super(key: key);

  List<Widget> _create() {
    List<Widget> res = [];
    titles.forEach((e) {
      res.add(InkWell(
        onTap: () => EasyLoading.showToast(e),
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 15),
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.symmetric(vertical: 15),
                child: Row(
                  children: [
                    Icon(imgs[titles.indexOf(e)]),
                    SizedBox(
                      width: 4,
                    ),
                    Text(
                      e,
                      style: AppFont.textStyle(14),
                    ),
                    Spacer(),
                    Icon(
                      Icons.arrow_forward_ios_outlined,
                      color: Colors.grey[400],
                      size: 16,
                    )
                  ],
                ),
              ),
              Visibility(
                visible: titles.indexOf(e) < titles.length - 1,
                child: Divider(
                  height: 1,
                ),
              )
            ],
          ),
        ),
      ));
    });
    return res;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(top: 15, left: 15, right: 15),
      decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(12)),
      child: Column(
        children: _create(),
      ),
    );
  }
}
